#pragma once

#include "TreeControl.h"
#include "DLL.h"
#include "Property.h"

namespace My {

class PropertyRow;
class PropertyRowSet;

class PropertyEditor : public virtual EventListener {
public:
	bool IsEmpty() const;
	void Open(EditableObject *);
	void Open(const EditableList &);
	void Close();
protected:
	void OpenProperties(const PropertyMap &);
	virtual PropertyRowSet & GetRows() = 0;
private:
	EditableList				m_Objects;
	std::vector<PropertyRow *>	m_Rows;
};

class PropertyRowSet : 
	public RowSet,
	public Widget,
	public PropertyEditor
{
public:
	PropertyRowSet(PropertyRow * = 0);
	PropertyRow * GetParentRow() const
		{ return m_pParent; }
protected:
	virtual int GetOffset() const
		{ return 0; }
	virtual PropertyRowSet & GetRows()
		{ return * this; }
private:
	PropertyRow *	m_pParent;
};

class PropertyRow : public TreeRow 
{
public:
	PropertyRow(PropertyRowSet &, const String &, PropertyBase *);
private:
	String			m_Caption;
	PropertyBase *	m_pProperty;
	Widget *		m_pControl;
	Widget *		m_pExtControl;
	PropertyRow *	m_pParent;
	PropertyRowSet	m_Children;
};

/*
class DLL_API PropertyEditor :	
	public Widget,
	private Container
{	
	friend class PropertyList;
	friend class PropertyRow;
	friend class VSplitter;
	friend class HSplitter;
	friend class InfoPanel;

	class VSplitter	: public Control {
	private:
		PEditor	&		m_Editor;
		PropertyList &	m_List;
		int				m_Pos;
		int				m_Start;
	public:
		VSplitter(PEditor &);
	public:
		virtual CRect Bounds() const;
		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
		virtual bool HandleCursor(unsigned int flags, const CPoint & p);
	};

	class HSplitter	: public Control {
	private:
		PEditor	&		m_Editor;
		int				m_Pos;
		int				m_Start;
	public:
		HSplitter(PEditor &);
	public:
		virtual CRect Bounds() const;
		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
		virtual bool HandleCursor(unsigned int flags, const CPoint & p);
	};

	class InfoPanel	: public Control {
	private:
		PEditor	&			m_Editor;
		CFont				m_Font;
		SysColorGlyph		m_Glyph;
	public:
		InfoPanel(PEditor &);
	public:
		virtual CRect Bounds() const;
		virtual bool Visible() const;
		virtual const CFont * Font() const;
		virtual void HandlePaint(CDC * pDC, const CRect & r);
	};

public:
	typedef std::map<PropertyBase *, bool> StateMap;

private:
	EditableList				m_Objects;
	PropertyList				m_List;
	InfoPanel					m_Info;
	bool						m_InfoVisible;
	VSplitter					m_VSplitter;
	HSplitter					m_HSplitter;
	std::vector<RowControl *>	m_Rows;
	int							m_CaptionWidth;
	int							m_InfoHeight;
	SysColorGlyph				m_ButtonUp;
	SysColorGlyph				m_ButtonDown;
	StateMap					m_StateMap;
	PropertyBase *				m_pSavedActive;
private:
	void OpenProperties(const PropertyMap & map);
	int GetCaptionWidth() const;
	void SetCaptionWidth(int w);
	void UpdateCaptionWidth()
		{ SetCaptionWidth(m_CaptionWidth); }
	int GetInfoHeight() const;
	void SetInfoHeight(int h);
	void UpdateInfoHeight()
		{ SetInfoHeight(m_InfoHeight); }
public:
	PEditor();
	~PEditor();
public:
	virtual CRect Bounds() const
		{ return Widget::Bounds(); }
	virtual bool Visible() const
		{ return Widget::Visible(); }
public:
	virtual void ProcessEvent(Event &);
	virtual void UpdateBounds();
	virtual void HandlePaint(CDC * pDC, const CRect & r);
	virtual bool HandleCursor(unsigned int flags, const CPoint & p);
public:
	bool IsEmpty() const;
	void Open(EditableObject * pObject);
	void Open(const EditableList & list);
	void Update();
	void InvalidateInfo();
	void Close();
	void ShowInfo(bool);
};
*/
} // My